package com.woniu.mapper;

import com.woniu.entity.Orders;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author 11370
* @description 针对表【orders】的数据库操作Mapper
* @createDate 2025-06-24 18:52:16
* @Entity com.woniu.entity.Orders
*/
public interface OrdersMapper {
    @Insert("insert into orders (order_id,user_id, total, status, created_at, updated_at) values (#{order_id},#{user_id},#{total},#{status},#{created_at},#{updated_at})")
    void insertOrder(Orders orders);

    @Select("select * from orders where user_id=#{uid}")
    public List<Orders> selectAllOrdersByUid(Integer uid);

    @Delete("delete from orders where user_id=#{uid}")
    public void deleteOrders(Integer uid);

    @Select("select * from orders")
    public List<Orders> selectAllOrders();

    @Update("update orders set status=#{status} where order_id=#{order_id}")
    public void updateOrdersStatus(@Param("order_id") Integer order_id, @Param("status") Integer status);

    @Select("select * from orders where order_id=#{order_id}")
    public Orders selectOrdersByOrderID(Integer order_id);

    @Update("update orders set total= total-#{price} where order_id=#{order_id}")
    public void updateOrderstotal(@Param("order_id") Integer order_id, @Param("price") double price);

    @Delete("delete from orders where order_id=#{order_id}")
    public void deleteOrdersByorderId(Integer order_id);

    @Select("select * from orders where status=#{status}")
    public List<Orders> selectOrdersBStatus(int status);

    @Select("select * from orders where user_id=#{uid} and status=#{status}  ")
    public List<Orders> selectOrdersUidStatus(@Param("uid") int uid , @Param("status") int status );
}




